import { reqCategoryApi } from '../../api/category'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    categoryList: [],
    activeIndex: 0
  },
  async getCategoryData() {
    const res = await reqCategoryApi()
    this.setData({
      categoryList: res.data
    })
  },
  // 左侧菜单激活
  changeIndex (e) {
    const { index } = e.currentTarget.dataset
    this.setData({
      activeIndex: index
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad() {
    this.getCategoryData()
  },
})